﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Portal;
using Microsoft.SharePoint.Publishing;

using Mystery.SharePoint;

namespace Mystery.SharePoint.Server
{
    public static class RatingExtensions
    {
        public static void EnableRating(this SPList list)
        {
            if (list == null) throw new ArgumentNullException("list");

            try
            {
                list.AddField(FieldId.AverageRatings,
                     SPAddFieldOptions.AddFieldToDefaultView |
                     SPAddFieldOptions.AddFieldInternalNameHint |
                     SPAddFieldOptions.AddToAllContentTypes);

                list.AddField(FieldId.RatingsCount,
                     SPAddFieldOptions.AddFieldInternalNameHint |
                     SPAddFieldOptions.AddToAllContentTypes);
            }
            catch (Exception ex)
            {
                Logger.L.AddException(Category.Provisioning, ex);
            }
        }
    }
}
